import { Component, OnInit,Input } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router';
import { Platform,NavController  } from '@ionic/angular';

interface RightBtnProperties{
  showRightBtn:boolean,
  isIonicIcon:boolean,
  rightBtnText:string
}

@Component({
  selector: 'app-common-header',
  templateUrl: './common-header.page.html',
  styleUrls: ['./common-header.page.scss'],
})
export class CommonHeaderPage implements OnInit {

  @Input() title:string;

  @Input() routerUrl:string = '';

  @Input() showBackBtn:boolean = true;

  @Input() rightBtnProperties:RightBtnProperties = {
    showRightBtn:false,
    isIonicIcon:false,//ionic icon  OR  text
    rightBtnText:''
  }

  @Input() rightBtnRun:Function;

  constructor(private router: Router,public navController: NavController) { 

  }

  ngOnInit() {
  }

  routerBack(){
    if(this.routerUrl && this.routerUrl.length>0){
      this.router.navigate([this.routerUrl]);
    }else{
      this.navController.back();
    }  
  }

  rightBtnClickEvent(){
    this.rightBtnRun();
  }
}
